<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.trkj.com/tr1702/tags" prefix="my" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>组织区域</title>
	<style type="text/css">
		 
	</style>
</head>
<body>
<script type="text/javascript">
				var removes = function(value,row,index){
					<my:g id="71"> 
					var orgareaId1remove="<a buttons='cf-button-del' onclick='delrow("+row.orgareaId1+")'>删除</a>";
					</my:g>
					return orgareaId1remove;
				}
				 
				var delrow = function(orgareaId1,row){
					  
						$.messager.confirm('确认', '您确定要删除该角色吗？', function(v){
							if(v){
								$.post("organizationArea_remove",{orgareaId1:orgareaId1},function(v){
									$('#cf-regional-tb').datagrid('reload');
								});
							}
						});
						 
				}
				var editrow = function(orgareaId1){
					<my:g id="72"> 
					$("<form method='get'>").appendTo(document.body).form({
						url:'organizationArea_update',
						onSubmit:function(param){
							var vv=$('#cf-regional-tb').datagrid('getSelected');
							//alert(vv.orgareaId1);
							param["orgareaId1"]= vv.orgareaId1;
							param["orgareaName"]=$('#cf-regional-name').textbox('getText');
							param["orgareaRemark"]=$('#cf-regional-remark').textbox('getText');
						},
						success:function(){
							$('#cf-regional-tb').datagrid('reload');
							$('#cf-regional-win').dialog('close');
						}
					}).submit().appendTo(".abc");					
					</my:g>	 
				}
			$(function(){
				$("#cf-regional-tb").datagrid({onLoadSuccess: function(){
					$("a[buttons=cf-button-del]").linkbutton({iconCls:'icon-cancel',plain:true});
				}});
			
				//打开添加
				$("#cf-regional-add").linkbutton({
					onClick : function() {
						$("#cf-regional-f").form('clear');
						$("#cf-regional-win").dialog("open");
						/* parent.$('.dialog-button a:eq(0)').show();
						parent.$('.dialog-button a:eq(1)').hide(); */
						$('#cf-zzqy-1').show();
						$('#cf-zzqy-2').hide();
					}
				});
				//刷新
				$("#cf-regional-refresh").linkbutton({onClick:function(){
					$("#cf-regional-tb").datagrid("reload");
				}});
				$("#cf-regional-tb").datagrid({
					onDblClickRow:function(index,row){
						
						$('#cf-regional-name').textbox('setText',row.orgareaName);
						$('#cf-regional-remark').textbox('setText',row.orgareaRemark);
						$("#cf-regional-win").dialog("open");
						/* parent.$('.dialog-button a:eq(1)').show();
						parent.$('.dialog-button a:eq(0)').hide(); */
						$('#cf-zzqy-1').hide();
						$('#cf-zzqy-2').show();
					}
				});						
			});
	</script>
	<div class="abc"></div>
	<div id="cf-regional-tbs2">
	 	<my:g id="70">
   		 <a id="cf-regional-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,text:'添加'"></a>
    	 </my:g>
 	<a id="cf-regional-refresh" class="easyui-linkbutton" data-options="iconCls:'icon-reload',text:'刷新',plain:true,iconAlign:'right'"></a>
    	 <input class="easyui-searchbox" data-options="label:'搜索',width:300,labelWidth:50,prompt:'区域名称',
     	searcher:function(value,name){
	        $('#cf-regional-tb').datagrid('load','organizationArea_searchbox?orgareaName='+value);
     	 }">
  </div>
		<table id="cf-regional-tb" class="easyui-datagrid" data-options="
			url:'areapages',
			fitColumns:true,
			fit:true,
			nowrap:false,
			loading:true,
			pagination:true,
			rownumbers:true,
			singleSelect:true,
			pageSize:10,
    		pageList:[10,20,30,40,50],
			toolbar:'#cf-regional-tbs2',
			striped:true,
			method:'get'	
	">
		<thead>
		  <tr>
			<th data-options="field:'orgareaId1',width:200,align:'center'">组织区域编号</th>
			<th data-options="field:'orgareaName',width:200,align:'center',
				styler:function(value,row,index){
					if(value==123){
						return 'color:white;background:red;';
					}
				}
			">区域名称</th>
			<th data-options="field:'orgareaRemark',width:200,align:'center'">备注</th>
			<th data-options="field:'xxx',width:100,align:'center',formatter:removes"></th>
		  </tr>	
		</thead>
		<tbody>
			 
		</tbody>
	</table>
<div id="cf-regional-win" class="easyui-dialog"data-options="width:450, height:330,
			title:'组织区域',
     		bodyCls:'organizationadd',
      		modal:true,
      		closed:true,
      		buttons:[{
	        	text:'添加',
				id:'cf-zzqy-1',
	        	iconCls:'icon-ok',
	        		handler:function(){
	          		 $('#cf-regional-f').form({
	            		onSubmit:function(param){
	            		 //验证表单
							var cc=$('#cf-regional-ids').textbox('getValue');
	             		 return $(this).form('validate');
	            		},
		           		 success:function(v){
		              		//$.messager.alert('提示','添加成功');
							$('#cf-regional-tb').datagrid('reload');
		              		$('#cf-regional-win').dialog('close');
		            	}
	          	    }).submit();
	       		  }
	      		},{
	        	text:'保存',
				id:'cf-zzqy-2',
	        	iconCls:'icon-save',
		        	handler:editrow
				},{
	        	text:'取消',
	        	iconCls:'icon-cancel',
		        	handler:function(){
		          		$('#cf-regional-win').dialog('close');
		        	}
				}
			]">
		<form id="cf-regional-f" action="organizationadd" method="get">
			<div class="cf-regional-line" style="margin-left:0px;padding:10px">
				       组织区域编号 <input style="margin-left:0px;padding:0px" id="cf-regional-ids" class="easyui-textbox"
				 name="orgareaId1" data-options="width:170,required:true">
			</div>
			
			<div class="cf-regional-line" style="margin-left:0px;padding:10px">
				        组织区域名称<input class="easyui-textbox" name="regionName"  id="cf-regional-rename"
					data-options="width:170,required:true">
			</div>
			
			<div class="cf-regional-line" style="margin-left:0px;padding:10px">
				        <input class="easyui-textbox" name="orgareaName"  id="cf-regional-name"
					data-options="label:'区域名称',width:'250'">  
			</div>
			<div class="cf-regional-line" style="margin-left:0px;padding:10px">
				        <input class="easyui-textbox" name="orgareaRemark"  id="cf-regional-remark"
					data-options="label:'备注',width:350,multiline:true
					,height:70">
			</div>
		</form>
	</div>

</body>
</html>